package com.mlink.web;

import com.mlink.entity.RecordCountEntity;
import com.mlink.mapper.RecordCountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RecordCountController {
	
	@Autowired
	private RecordCountMapper recordConutMapper;




   /*
    * 获取日志列表信息
    *
    * */
    @RequestMapping(value = "/getRecordCountList",method = RequestMethod.GET)
    public List<RecordCountEntity> getRecordCountDay(@RequestParam(value = "start", required = true) int start,  //  required = false  int 要换成Integer
                                         @RequestParam(value = "num", required = true) int num,
                                         @RequestParam(value = "userID", required = false) Integer userID,
                                         @RequestParam(value = "projectID", required = false) Integer projectID,
                                          @RequestParam(value = "tjzq", required = false) Integer tjzq,
                                          @RequestParam(value = "sort", required = false) Integer sort,
                                         @RequestParam(value = "date", required = false) String date) {
        List<RecordCountEntity> users = null;
         if(tjzq == 0) {
              users = recordConutMapper.getRecordDay(start, num, userID, projectID, date);
             return  users;
         } else {
             if (userID == -1 && projectID == -1) {
                 if(sort == null) sort =0;
                users=recordConutMapper.getRecordAllSel(start,num, userID, projectID,  date, tjzq,sort);
             }
             if (userID == -1 && projectID != -1  ) {
                 users=recordConutMapper.getRecordProSel(start,num, userID, projectID,  date, tjzq);
             }
             if (userID != -1 && projectID == -1  ) {
                 users=recordConutMapper.getRecordUserSel(start,num, userID, projectID,  date, tjzq);
             }
             if (userID != -1 && projectID != -1  ) {
                 users=recordConutMapper.getRecordUserProSel(start,num, userID, projectID,  date, tjzq);
             }
         }

        return users;
    }


}